﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Tools.Ribbon;




namespace WordAddIn1
{
    public partial class MyBlogsUserControl : UserControl
    {
        public MyBlogsUserControl()
        {
            InitializeComponent();
        }
        ThisAddIn app
        {
            get
            {
                return Globals.ThisAddIn;
            }

        }

        private void MyBlogsUserControl_VisibleChanged(object sender, EventArgs e)
        {

        }

        private void InsertPicBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "jpg files (*.jpg)|*.jpg|png files|*.png";
            dlg.FilterIndex = 1;//如果您设置 FilterIndex 属性，则当显示对话框时，将选择该筛选器。
            dlg.RestoreDirectory = true;//取得或设定值，指出对话方块是否在关闭前还原目前的目录。

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                app.InsertPic(dlg.FileName);
            }
        }

        private void InsertTxtBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "txt files|*.txt";
            dlg.FilterIndex = 1;//如果您设置 FilterIndex 属性，则当显示对话框时，将选择该筛选器。
            dlg.RestoreDirectory = true;//取得或设定值，指出对话方块是否在关闭前还原目前的目录。

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                app.InsertTxt(dlg.FileName);
            }
        }

        private void applyTemp_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "doc files|*.doc|docx files|*.docx";
            dlg.FilterIndex = 1;//如果您设置 FilterIndex 属性，则当显示对话框时，将选择该筛选器。
            dlg.RestoreDirectory = true;//取得或设定值，指出对话方块是否在关闭前还原目前的目录。

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                app.ApplyTemplete(dlg.FileName);
            }
        }

        private void exportPicBtn_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "图片(*.jpg)|*.jpg";
            sfd.InitialDirectory = "C:\\";
            sfd.FilterIndex = 0;
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                app.ExportPic(sfd.FileName);
            }

        }

        private void ExportTxt_Click(object sender, EventArgs e)
        {
            
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "txt file(*.txt)|*.txt";
            sfd.InitialDirectory = "C:\\";
            sfd.FilterIndex = 0;
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                app.ExportTxt(sfd.FileName);
            }
        }

    }
}
